Skip to content

miner: simplify code for simulating bids#3135

Merged
zzzckck merged 1 commit intobnb-chain:developfrom
buddh0:simplify-code-for-simulating-bids
Jun 3, 2025
Merged

miner: simplify code for simulating bids#3135
zzzckck merged 1 commit intobnb-chain:developfrom
buddh0:simplify-code-for-simulating-bids

Conversation

@buddh0
Copy link
Contributor

@buddh0 buddh0 commented May 30, 2025

Description

miner: simplify code for simulating bids

Rationale

mini logic changes, clear more than 20+ lines code

Example

add an example CLI or API response...

Changes

Notable changes:

  • add each change in a bullet point here
  • ...

@buddh0 buddh0 marked this pull request as draft May 30, 2025 10:19
if bestBid == nil {
winResult := "true[first]"
if bestBidOnStart != nil {
// new block was imported, so the bestBidOnStart was cleared, the bid will be stale and useless.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

won't happen, clear bestBid delayed a lot of blocks(TriesInMemory).

}

// only recommit last best bid when newBidCh is empty
if len(b.newBidCh) > 0 {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

recommit logic not depend on bid simulation.

@buddh0 buddh0 marked this pull request as ready for review May 30, 2025 10:36
@zzzckck zzzckck requested a review from Copilot June 3, 2025 06:07
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR simplifies the bid simulation logic by removing redundant code and streamlining the best bid update and logging processes. The changes focus on removing the previously used bestBidOnStart variable, revising the logging conditions, and adjusting the bid comparison logic.

  • Removed bestBidOnStart and related stale bid handling logic.
  • Modified logging conditions to always log with simElapsed and adjusted bid comparison from >= to >.
  • Updated the best bid selection block to combine nil-check and reward comparison.
Comments suppressed due to low confidence (3)

miner/bid_simulator.go:864

  • [nitpick] Since the best bid is updated here when bestBid is nil or a better bid is received, consider adding a comment to explain how this update integrates with the earlier logging logic for clarity.
b.SetBestBid(bidRuntime.bid.ParentHash, bidRuntime)

miner/bid_simulator.go:845

  • Review the change in logging logic: previously winResult was dynamically adjusted based on bestBidOnStart, but now it is always reported as 'true[first]' when bestBid is nil. Confirm that this simplified approach meets the intended simulation outcome.
log.Info("[BID RESULT]", "win", winResult, "builder", bidRuntime.bid.Builder, "hash", bidRuntime.bid.Hash().TerminalString(), "simElapsed", time.Since(startTS))

miner/bid_simulator.go:848

  • Ensure that updating the condition from '>=' to '>' for comparing packedBlockReward is intended, since equal bids will no longer be considered improvements.
"win", bidRuntime.packedBlockReward.Cmp(bestBid.packedBlockReward) > 0,

@zzzckck zzzckck merged commit cb9243a into bnb-chain:develop Jun 3, 2025
7 checks passed
sysvm pushed a commit to sysvm/bsc that referenced this pull request Jun 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants